//
//  KehuXinZengViewController.m
//  HondaPro_2
//
//  Created by ht on 13-7-23.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "KehuXinZengViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "HelpClass.h"
#import "SVProgressHUD.h"
#import "webConfig.h"
#import "webService.h"
#import "MyAFNetWorkManager.h"
@interface KehuXinZengViewController ()<UITextFieldDelegate,UITextViewDelegate>
{
BOOL _yonghuchoose;
}
@end

@implementation KehuXinZengViewController

@synthesize noteTextView = _noteTextView;

@synthesize editNewfield1 = _editNewfield1;
@synthesize editNewfield2 = _editNewfield2;
@synthesize editNewfield3 = _editNewfield3;
@synthesize editNewfield4 = _editNewfield4;
@synthesize editNewfield5 = _editNewfield5;
@synthesize editNewfield6 = _editNewfield6;
@synthesize editNewfield7 = _editNewfield7;
@synthesize editNewfield8 = _editNewfield8;
@synthesize editNewfield9 = _editNewfield9;

@synthesize editNewbutton1 = _editNewbutton1;
@synthesize editNewbutton2 = _editNewbutton2;
@synthesize editNewbutton3 = _editNewbutton3;
@synthesize editNewbutton4 = _editNewbutton4;
@synthesize editNewbutton5 = _editNewbutton5;
@synthesize editNewbutton6 = _editNewbutton6;
@synthesize editNewbutton7 = _editNewbutton7;
@synthesize editNewbutton8 = _editNewbutton8;
@synthesize editNewbutton9 = _editNewbutton9;
@synthesize editNewbutton10 = _editNewbutton10;

@synthesize baocunButton = _baocunButton;
@synthesize guanbiButton = _guanbiButton;
@synthesize containerView = _containerView;
@synthesize yonghu = yonghu;
@synthesize customerInsideDit = _customerInsideDit;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.provinceArray = [[NSMutableArray alloc]init];//省
    self.cityArray = [[NSMutableArray alloc]init];//市
    self.countyArray = [[NSMutableArray alloc]init];//地区
    self.CTtypeArray = [[NSMutableArray alloc]init];//身份证类型
    
    self.hobbyIdArray =[[NSMutableArray alloc]init];//兴趣爱好

    //通用代码表的字典
   self.dicTmp = [HelpClass returnTheDataByJsonFileAndJustForTestWithFileName:@"codeA" andType:@"json"];
    [SVProgressHUD dismiss];

    self.containerView = [[UIView alloc]initWithFrame:CGRectMake(70, 100, 1024-70-70, 668)];
    [self.containerView setBackgroundColor:[UIColor clearColor]];
    [self.view addSubview:self.containerView];
    //测试label
//    _ceshi = [[UILabel alloc]initWithFrame:CGRectMake(750, 350, 150, 30)];
//    _ceshi.text=@"0";
//    _ceshi.hidden=YES;
//    _ceshi.textColor = [UIColor whiteColor];
//    [self.containerView addSubview:_ceshi];

    [self content];
    [self AVarietyOfTextField];
    [self AVarietyOfButton];
    //注册键盘即将消失的消息
   [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardHide:)
                                                name:UIKeyboardDidHideNotification
                                              object:nil];
    if ([_CLStatus isEqualToString:@"bj"] ) {
        [self BJUI];
    }
}
-(void)BJUI{

//    NSLog(@"LALA");
    self.editNewfield1.text = _khbhStr;
    self.editNewfield2.text = _khmcStr;
    self.editNewfield3.text = _sjhStr;
    self.editNewfield4.text = _lxrStr;
    self.editNewfield5.text = _lxdhStr;
    self.editNewfield6.text = _lxdzStr;
    self.editNewfield7.text = _ybStr;
    self.editNewfield9.text = _zjhmStr;
    self.noteTextView.text = _bzStr;
    [self.editNewbutton2 setTitle:_khxzStr forState:UIControlStateNormal];

    [self.diQuSheng setTitle:_privenceStr forState:UIControlStateNormal];
    [self.diQuShi setTitle:_cityStr forState:UIControlStateNormal];
    [self.diQuDiqu setTitle:_areaStr forState:UIControlStateNormal];

    [self.editNewbutton3 setTitle:_xbStr forState:UIControlStateNormal];

    [self.editNewbutton4 setTitle:_csrqStr forState:UIControlStateNormal];

    [self.editNewbutton5 setTitle:_zjlxStr forState:UIControlStateNormal];

      [self.editNewbutton7 setTitle:_xqahStr forState:UIControlStateNormal];

      [self.editNewbutton8 setTitle:_hyztStr forState:UIControlStateNormal];
    
    
    
    //   为请求中的个别字段赋值
    
// self.provinceId
    NSArray *zidianArr=[self readershuDICimform][@"PROVINCE"];
    for(NSDictionary *dic in zidianArr)
    {
        if ([dic[@"NAME"] isEqualToString:_privenceStr]) {
            self.provinceId = [dic[@"CODE"] stringValue];
        }
    }
    
    
//    self.cityId
    NSArray *zidianArr1=[self readershuDICimform][@"CITY"];
    for(NSDictionary *dic in zidianArr1)
    {
        if ([dic[@"NAME"] isEqualToString:_cityStr]) {
            self.cityId = [dic[@"CODE"] stringValue];
        }
    }
    
//    self.countyId 
    NSArray *zidianArr2=[self readershuDICimform][@"AREA"];
    for(NSDictionary *dic in zidianArr2)
    {
        if ([dic[@"NAME"] isEqualToString:_areaStr]) {
            self.countyId = [dic[@"CODE"] stringValue];
        }
    }
    
//    self.CTtypeID
    NSArray *zidianArr3=[self readershuDICimform][@"CT_CODE"];
    for(NSDictionary *dic in zidianArr3)
    {
        if ([dic[@"NAME"] isEqualToString:_zjlxStr]) {
            self.CTtypeID = dic[@"CODE"];
        }
    }
    
//    self.hobbyId
    NSArray *zidianArr4=[self readershuDICimform][@"TM_HOBBY"];
    for(NSDictionary *dic in zidianArr4)
    {
        if ([dic[@"NAME"] isEqualToString:_xqahStr]) {
            self.hobbyId = dic[@"CODE"];
        }
    }
    
    
//    CT_CODE   TM_HOBBY
//    NSLog(@"----%@--%@---%@---%@---%@",self.provinceId,self.cityId,self.countyId,self.CTtypeID,self.hobbyId);
    
    
    
    
}
-(void)viewWillAppear:(BOOL)animated
{
//    [self addNotification];
}
#pragma mark - 各种输入框
-(void)AVarietyOfTextField
{
    self.editNewfield1 = [[UILabel alloc]initWithFrame:CGRectMake(95, 65, 165, 30)];    //客户编号
    self.editNewfield1.textColor = [UIColor grayColor];
    self.editNewfield1.font = [UIFont fontWithName:@"ArialMT" size:15];
    self.editNewfield1.layer.borderColor = [[UIColor grayColor]CGColor];
    self.editNewfield1.layer.borderWidth = 1;
//    self.editNewfield1.text = [self.customerInsideDit objectForKey:@"customerId"];
    [self.editNewfield1 setTextAlignment:NSTextAlignmentCenter];
    [self.containerView addSubview:self.editNewfield1];
    
    self.editNewfield2 = [[UITextField alloc]initWithFrame:CGRectMake(95, 110, 165, 30)];    //客户名称
    self.editNewfield2.borderStyle = UITextBorderStyleLine;
    self.editNewfield2.textColor = [UIColor grayColor];
    self.editNewfield2.font = [UIFont fontWithName:@"ArialMT" size:15];
//    self.editNewfield2.text = [self.customerInsideDit objectForKey:@"customerName"];
    [self.editNewfield2 setTextAlignment:NSTextAlignmentCenter];
    self.editNewfield2.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.containerView addSubview:self.editNewfield2];
    
    self.editNewfield3 = [[UITextField alloc]initWithFrame:CGRectMake(95, 155, 165, 30)];    //手机号
    self.editNewfield3.borderStyle = UITextBorderStyleLine;
    self.editNewfield3.keyboardType=UIKeyboardTypeNumberPad;
    self.editNewfield3.textColor = [UIColor grayColor];
    self.editNewfield3.font = [UIFont fontWithName:@"ArialMT" size:15];
    self.editNewfield3.delegate = self;
//    self.editNewfield3.text = [self.customerInsideDit objectForKey:@"mobile"];
    [self.editNewfield3 setTextAlignment:NSTextAlignmentCenter];
    self.editNewfield3.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.containerView addSubview:self.editNewfield3];
    
//    self.editNewfield4 = [[UITextField alloc]initWithFrame:CGRectMake(95, 288, 165, 30)];
    self.editNewfield4 = [[UITextField alloc]initWithFrame:CGRectMake(95, 243, 165, 30)];
       //联系人
    self.editNewfield4.borderStyle = UITextBorderStyleLine;
    self.editNewfield4.textColor = [UIColor grayColor];
    self.editNewfield4.font = [UIFont fontWithName:@"ArialMT" size:15];
//    self.editNewfield4.text = [self.customerInsideDit objectForKey:@"contactMan"];
    [self.editNewfield4 setTextAlignment:NSTextAlignmentCenter];
    self.editNewfield4.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
//        self.editNewfield4.delegate = self;
    [self.containerView addSubview:self.editNewfield4];
    
//    self.editNewfield5 = [[UITextField alloc]initWithFrame:CGRectMake(95, 333, 165, 30)];    //联系电话
    self.editNewfield5 = [[UITextField alloc]initWithFrame:CGRectMake(95, 288, 165, 30)];
    self.editNewfield5.borderStyle = UITextBorderStyleLine;
    self.editNewfield5.textColor = [UIColor grayColor];
        self.editNewfield5.keyboardType=UIKeyboardTypeNumberPad;
    self.editNewfield5.font = [UIFont fontWithName:@"ArialMT" size:15];
//    self.editNewfield5.text = [self.customerInsideDit objectForKey:@"tel"];
    [self.editNewfield5 setTextAlignment:NSTextAlignmentCenter];
    self.editNewfield5.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
//        self.editNewfield5.delegate = self;
    [self.containerView addSubview:self.editNewfield5];
    
    
    
    self.editNewfield6 = [[UITextField alloc]initWithFrame:CGRectMake(380, 65, 400, 30)];    //联系地址
    self.editNewfield6.borderStyle = UITextBorderStyleLine;
    self.editNewfield6.textColor = [UIColor grayColor];
    self.editNewfield6.font = [UIFont fontWithName:@"ArialMT" size:15];
//    self.editNewfield6.text = [self.customerInsideDit objectForKey:@"address"];
    [self.editNewfield6 setTextAlignment:NSTextAlignmentCenter];
    self.editNewfield6.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.containerView addSubview:self.editNewfield6];
    
    self.editNewfield7 = [[UITextField alloc]initWithFrame:CGRectMake(380, 110, 165, 30)];    //邮编
    self.editNewfield7.borderStyle = UITextBorderStyleLine;
    self.editNewfield7.textColor = [UIColor grayColor];
    self.editNewfield7.font = [UIFont fontWithName:@"ArialMT" size:15];
//    self.editNewfield7.text = [self.customerInsideDit objectForKey:@"zipcode"];
    self.editNewfield7.keyboardType=UIKeyboardTypeNumberPad;
    [self.editNewfield7 setTextAlignment:NSTextAlignmentCenter];
    self.editNewfield7.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.containerView addSubview:self.editNewfield7];
    
//    self.editNewfield8 = [[UITextField alloc]initWithFrame:CGRectMake(380, 155, 165, 30)];    //传真
//    self.editNewfield8.borderStyle = UITextBorderStyleLine;
//    self.editNewfield8.textColor = [UIColor grayColor];
//    self.editNewfield8.font = [UIFont fontWithName:@"ArialMT" size:15];
////    self.editNewfield8.text = [self.customerInsideDit objectForKey:@"fax"];
//    self.editNewfield8.keyboardType=UIKeyboardTypeNumberPad;
//    [self.editNewfield8 setTextAlignment:NSTextAlignmentCenter];
//    self.editNewfield8.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
//    [self.containerView addSubview:self.editNewfield8];
    
    self.editNewfield9 = [[UITextField alloc]initWithFrame:CGRectMake(380, 333-45, 220, 30)];    //证件号码
    self.editNewfield9.borderStyle = UITextBorderStyleLine;
    self.editNewfield9.textColor = [UIColor grayColor];
    self.editNewfield9.font = [UIFont fontWithName:@"ArialMT" size:15];
//    self.editNewfield9.text = [self.customerInsideDit objectForKey:@"certificate"];
    self.editNewfield9.keyboardType=UIKeyboardTypeNumberPad;
    [self.editNewfield9 setTextAlignment:NSTextAlignmentCenter];
    self.editNewfield9.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
//        self.editNewfield9.delegate = self;
    [self.containerView addSubview:self.editNewfield9];
    
    self.noteTextView = [[UITextView alloc]initWithFrame:CGRectMake(95, 427-45, 505, 120)];    //备注
    [self.noteTextView setFont:[UIFont fontWithName:@"ArialMT" size:14]];
    self.noteTextView.textColor = [UIColor grayColor];
    self.noteTextView.layer.borderColor = [[UIColor grayColor]CGColor];
    self.noteTextView.layer.borderWidth = 0.9;
//    self.noteTextView.text = [self.customerInsideDit objectForKey:@"remark"];
        self.noteTextView.delegate = self;
    [self.containerView addSubview:self.noteTextView];
}
#pragma mark - 各种选择按钮
-(void)AVarietyOfButton
{
//    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(95, 200, 165, 30)];
//    [label1 setBackgroundColor:[UIColor clearColor]];
//    label1.layer.borderColor = [[UIColor grayColor]CGColor];
//    label1.layer.borderWidth = 0.9;
//    [self.containerView addSubview:label1];
//    self.editNewbutton1 = [UIButton buttonWithType:UIButtonTypeCustom];         //客户来源
//    [self.editNewbutton1 setFrame:CGRectMake(96, 201, 163, 28)];
//    [self.editNewbutton1 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.editNewbutton1 addTarget:self action:@selector(editNewbutton1:) forControlEvents:UIControlEventTouchUpInside];
////    [self.editNewbutton1 setTitle:[self.customerInsideDit objectForKey:@"sourceName"] forState:UIControlStateNormal];
//    self.editNewbutton1.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.editNewbutton1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.containerView addSubview:self.editNewbutton1];
    
//    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(95, 243, 165, 30)];
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(95, 200, 165, 30)];
    [label2 setBackgroundColor:[UIColor clearColor]];
    label2.layer.borderColor = [[UIColor grayColor]CGColor];
    label2.layer.borderWidth = 0.9;
    [self.containerView addSubview:label2];
    self.editNewbutton2 = [UIButton buttonWithType:UIButtonTypeCustom];         //客户性质
//    [self.editNewbutton2 setFrame:CGRectMake(96, 244, 163, 28)];
    [self.editNewbutton2 setFrame:CGRectMake(96, 201, 163, 28)];
    [self.editNewbutton2 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.editNewbutton2 addTarget:self action:@selector(editNewbutton2:) forControlEvents:UIControlEventTouchUpInside];
//    [self.editNewbutton2 setTitle:[self.customerInsideDit objectForKey:@"natureName"] forState:UIControlStateNormal];
    self.editNewbutton2.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];

    [self.editNewbutton2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.editNewbutton2];
    
//    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(380, 200, 165, 30)];
//
    UILabel * label3 = [[UILabel alloc]initWithFrame:CGRectMake(380, 155, 165, 30)];
    [label3 setBackgroundColor:[UIColor clearColor]];
    label3.layer.borderColor = [[UIColor grayColor]CGColor];
    label3.layer.borderWidth = 0.9;
    [self.containerView addSubview:label3];
    self.editNewbutton3 = [UIButton buttonWithType:UIButtonTypeCustom];          //性别
    [self.editNewbutton3 setFrame:CGRectMake(381, 156, 163, 28)];
    [self.editNewbutton3 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.editNewbutton3 addTarget:self action:@selector(editNewbutton3:) forControlEvents:UIControlEventTouchUpInside];
//    [self.editNewbutton3 setTitle:[self.customerInsideDit objectForKey:@"gender"] forState:UIControlStateNormal];
    self.editNewbutton3.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.editNewbutton3 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.editNewbutton3];
    
//    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(380, 244, 165, 30)];
    UILabel * label4 = [[UILabel alloc]initWithFrame:CGRectMake(380, 200, 165, 30)];
    [label4 setBackgroundColor:[UIColor clearColor]];
    label4.layer.borderColor = [[UIColor grayColor]CGColor];
    label4.layer.borderWidth = 0.9;
    [self.containerView addSubview:label4];
    self.editNewbutton4 = [UIButton buttonWithType:UIButtonTypeCustom];          //出生日期
    [self.editNewbutton4 setFrame:CGRectMake(381, 201, 163, 28)];
    [self.editNewbutton4 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.editNewbutton4 addTarget:self action:@selector(editNewbutton4:) forControlEvents:UIControlEventTouchUpInside];
//    [self.editNewbutton4 setTitle:[self.customerInsideDit objectForKey:@"birthday"] forState:UIControlStateNormal];
    self.editNewbutton4.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.editNewbutton4 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.editNewbutton4];
    
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(380, 288-45, 165, 30)];
    [label5 setBackgroundColor:[UIColor clearColor]];
    label5.layer.borderColor = [[UIColor grayColor]CGColor];
    label5.layer.borderWidth = 0.9;
    [self.containerView addSubview:label5];
    self.editNewbutton5 = [UIButton buttonWithType:UIButtonTypeCustom];           //证件类型
    [self.editNewbutton5 setFrame:CGRectMake(381, 289-45, 163, 28)];
    [self.editNewbutton5 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.editNewbutton5 addTarget:self action:@selector(editNewbutton5:) forControlEvents:UIControlEventTouchUpInside];
//    [self.editNewbutton5 setTitle:[self.customerInsideDit objectForKey:@"certificateType"] forState:UIControlStateNormal];
    self.editNewbutton5.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.editNewbutton5 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.editNewbutton5];
    
//    UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(665, 110, 165, 30)];
//    [label6 setBackgroundColor:[UIColor clearColor]];
//    label6.layer.borderColor = [[UIColor grayColor]CGColor];
//    label6.layer.borderWidth = 0.9;
//    [self.containerView addSubview:label6];
//    self.editNewbutton6 = [UIButton buttonWithType:UIButtonTypeCustom];            //职业
//    [self.editNewbutton6 setFrame:CGRectMake(666, 111, 163, 28)];
//    [self.editNewbutton6 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.editNewbutton6 addTarget:self action:@selector(editNewbutton6:) forControlEvents:UIControlEventTouchUpInside];
////    [self.editNewbutton6 setTitle:[self.customerInsideDit objectForKey:@"job"] forState:UIControlStateNormal];
//    self.editNewbutton6.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.editNewbutton6 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.containerView addSubview:self.editNewbutton6];
    
    UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(665, 155-45, 165, 30)];
    [label7 setBackgroundColor:[UIColor clearColor]];
    label7.layer.borderColor = [[UIColor grayColor]CGColor];
    label7.layer.borderWidth = 0.9;
    [self.containerView addSubview:label7];
    self.editNewbutton7 = [UIButton buttonWithType:UIButtonTypeCustom];            //兴趣爱好
    [self.editNewbutton7 setFrame:CGRectMake(666, 156-45, 163, 28)];
    [self.editNewbutton7 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.editNewbutton7 addTarget:self action:@selector(editNewbutton7:) forControlEvents:UIControlEventTouchUpInside];
//    [self.editNewbutton7 setTitle:[self.customerInsideDit objectForKey:@"hobbies"] forState:UIControlStateNormal];
    self.editNewbutton7.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.editNewbutton7 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.editNewbutton7];
    
    UILabel *label8 = [[UILabel alloc]initWithFrame:CGRectMake(665, 199-45, 165, 30)];
    [label8 setBackgroundColor:[UIColor clearColor]];
    label8.layer.borderColor = [[UIColor grayColor]CGColor];
    label8.layer.borderWidth = 0.9;
    [self.containerView addSubview:label8];
    self.editNewbutton8 = [UIButton buttonWithType:UIButtonTypeCustom];            //婚姻状况
    [self.editNewbutton8 setFrame:CGRectMake(666, 200-45, 163, 28)];
    [self.editNewbutton8 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.editNewbutton8 addTarget:self action:@selector(editNewbutton8:) forControlEvents:UIControlEventTouchUpInside];
//    [self.editNewbutton8 setTitle:[self.customerInsideDit objectForKey:@"marital"] forState:UIControlStateNormal];
    self.editNewbutton8.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.editNewbutton8 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.editNewbutton8];
    
//    UILabel *label9 = [[UILabel alloc]initWithFrame:CGRectMake(665, 241, 165, 30)];
//    [label9 setBackgroundColor:[UIColor clearColor]];
//    label9.layer.borderColor = [[UIColor grayColor]CGColor];
//    label9.layer.borderWidth = 0.9;
//    [self.containerView addSubview:label9];
//    self.editNewbutton9 = [UIButton buttonWithType:UIButtonTypeCustom];            //生产厂家
//    [self.editNewbutton9 setFrame:CGRectMake(666, 242, 163, 28)];
//    [self.editNewbutton9 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.editNewbutton9 addTarget:self action:@selector(editNewbutton9:) forControlEvents:UIControlEventTouchUpInside];
////    [self.editNewbutton9 setTitle:[self.customerInsideDit objectForKey:@"originalfactory"] forState:UIControlStateNormal];
//    self.editNewbutton9.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.editNewbutton9 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.containerView addSubview:self.editNewbutton9];
//    
//    UILabel *label10 = [[UILabel alloc]initWithFrame:CGRectMake(665, 285, 165, 30)];
//    [label10 setBackgroundColor:[UIColor clearColor]];
//    label10.layer.borderColor = [[UIColor grayColor]CGColor];
//    label10.layer.borderWidth = 0.9;
//    [self.containerView addSubview:label10];
//    self.editNewbutton10 = [UIButton buttonWithType:UIButtonTypeCustom];            //车辆品牌
//    [self.editNewbutton10 setFrame:CGRectMake(666, 286, 163, 28)];
//    [self.editNewbutton10 setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
//    [self.editNewbutton10 addTarget:self action:@selector(editNewbutton10:) forControlEvents:UIControlEventTouchUpInside];
////    [self.editNewbutton10 setTitle:[self.customerInsideDit objectForKey:@"originalcar"] forState:UIControlStateNormal];
//    self.editNewbutton10.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
//    [self.editNewbutton10 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [self.containerView addSubview:self.editNewbutton10];
  
    UILabel *label11 = [[UILabel alloc]initWithFrame:CGRectMake(95, 333, 150, 30)];
    [label11 setBackgroundColor:[UIColor clearColor]];
    label11.layer.borderColor = [[UIColor grayColor]CGColor];
    label11.layer.borderWidth = 0.9;
    [self.containerView addSubview:label11];
    self.diQuSheng = [UIButton buttonWithType:UIButtonTypeCustom];             //省
    [self.diQuSheng setFrame:CGRectMake(96, 334, 148, 28)];
    [self.diQuSheng setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.diQuSheng addTarget:self action:@selector(diQuSheng:) forControlEvents:UIControlEventTouchUpInside];
    [self.diQuSheng setTitle:@"           -           " forState:UIControlStateNormal];
    self.diQuSheng.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.diQuSheng setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.diQuSheng];
    
    UILabel *label12 = [[UILabel alloc]initWithFrame:CGRectMake(255, 333, 150, 30)];
    [label12 setBackgroundColor:[UIColor clearColor]];
    label12.layer.borderColor = [[UIColor grayColor]CGColor];
    label12.layer.borderWidth = 0.9;
    [self.containerView addSubview:label12];
    self.diQuShi = [UIButton buttonWithType:UIButtonTypeCustom];             //市
    [self.diQuShi setFrame:CGRectMake(256, 334, 148, 28)];
    [self.diQuShi setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.diQuShi addTarget:self action:@selector(diQuShi:) forControlEvents:UIControlEventTouchUpInside];
    [self.diQuShi setTitle:@"           -           " forState:UIControlStateNormal];
    self.diQuShi.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.diQuShi setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.diQuShi];
    
    UILabel *label13 = [[UILabel alloc]initWithFrame:CGRectMake(415, 333, 150, 30)];
    [label13 setBackgroundColor:[UIColor clearColor]];
    label13.layer.borderColor = [[UIColor grayColor]CGColor];
    label13.layer.borderWidth = 0.9;
    [self.containerView addSubview:label13];
    self.diQuDiqu = [UIButton buttonWithType:UIButtonTypeCustom];             //地区
    [self.diQuDiqu setFrame:CGRectMake(416, 334, 148, 28)];
    [self.diQuDiqu setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.diQuDiqu addTarget:self action:@selector(diQuDiqu:) forControlEvents:UIControlEventTouchUpInside];
    [self.diQuDiqu setTitle:@"           -           " forState:UIControlStateNormal];
    self.diQuDiqu.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.diQuDiqu setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.containerView addSubview:self.diQuDiqu];
    
    self.saveButton = [[UIButton alloc]initWithFrame:CGRectMake(820, 65, 80, 35)];
    [self.saveButton setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    [self.saveButton setTitle:@"保 存" forState:UIControlStateNormal];
    [self.saveButton setTintColor:[UIColor whiteColor]];
    self.saveButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.saveButton addTarget:self action:@selector(saveButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.saveButton];
    
    //是否协议客户
//    self.yonghu = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.yonghu setFrame:CGRectMake(650, 331, 35, 36)];
//    [self.yonghu setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
//    [self.yonghu addTarget:self action:@selector(WarrantyOptions:) forControlEvents:UIControlEventTouchUpInside];
//    [self.containerView addSubview:self.yonghu];
//    UILabel *label14 = [[UILabel alloc]initWithFrame:CGRectMake(700, 333, 150, 30)];
//    label14.text=@"是否协议客户";
//    label14.textColor = [UIColor grayColor];
//    [self.containerView addSubview:label14];
  


}
//用户  按钮
-(void)WarrantyOptions:(id)sender
{
    if(_yonghuchoose == YES)
    {
        _yonghuchoose = NO;
        [self.yonghu  setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
        _ceshi.text=@"0";
        NSLog(@"0");
}
    else
    {
        _yonghuchoose = YES;
        [self.yonghu setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
        NSLog(@"1");
        _ceshi.text=@"1";
    }
}
////////////////////////////////////////////////////
///////////保存提示//////////////////////////////////
///////////////////////////////////////////////////
-(void)saveButton:(id)sender
{
//    NSLog(@"%@", _ceshi.text);
    //存储字典
    self.customerInsideDit = [[NSMutableDictionary alloc]init];
    if([self.diQuSheng.titleLabel.text isEqualToString:@"           -           "])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择省市地区" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else if(self.editNewfield2.text == nil || [self.editNewfield2.text isEqualToString:@""])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"客户名称不能为空" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else if(self.editNewfield3.text.length != 11)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"手机号不合法，请重新输入" delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil];
        [alert show];
    }
    else if(self.editNewfield4.text == nil || [self.editNewfield4.text isEqualToString:@""])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"联系人不能为空" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else if(self.editNewfield5.text == nil || [self.editNewfield5.text isEqualToString:@""])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"联系电话不能为空" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else
    {
    
        //拿到已编辑好数据
//        self.customerInsideDit = [[NSMutableDictionary alloc]initWithCapacity:10];
        self.customerInsideDit = [[NSMutableDictionary alloc]init];
        //客户名称
        if(self.editNewfield2.text != nil)
        {
            NSString *strB = [self.editNewfield2.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            [self.customerInsideDit setObject:strB forKey:@"CUSTOMER_NAME"];
        }
        //手机号
        if(self.editNewfield3.text == nil || [self.editNewfield3.text isEqualToString:@""])
        {
            self.editNewfield3.text = @"";
        }
        [self.customerInsideDit setObject:self.editNewfield3.text forKey:@"MOBILE"];
        //客户来源
//        if([self.editNewbutton1.titleLabel.text isEqualToString:@"自然来店"])
//        {
//            [self.customerInsideDit setObject:@"A1" forKey:@"sourceId"];
//        }
//        if([self.editNewbutton1.titleLabel.text isEqualToString:@"保有增购/换购"])
//        {
//            [self.customerInsideDit setObject:@"A2" forKey:@"sourceId"];
//        }
//        if([self.editNewbutton1.titleLabel.text isEqualToString:@"情报提供"])
//        {
//            [self.customerInsideDit setObject:@"A3" forKey:@"sourceId"];
//        }
//        if([self.editNewbutton1.titleLabel.text isEqualToString:@"店外开发"])
//        {
//            [self.customerInsideDit setObject:@"A4" forKey:@"sourceId"];
//        }
//        if([self.editNewbutton1.titleLabel.text isEqualToString:@"保有推介"])
//        {
//            [self.customerInsideDit setObject:@"A5" forKey:@"sourceId"];
//        }
        //客户性质
        if ([self.editNewbutton2.titleLabel.text isEqualToString:@"公司"]) {
            [self.customerInsideDit setValue: @"11901001" forKey:@"NATURE_ID"];
        }
        if ([self.editNewbutton2.titleLabel.text isEqualToString:@"个人"]) {
            [self.customerInsideDit setValue: @"11901002" forKey:@"NATURE_ID"];
        }
//        if([self.editNewbutton2.titleLabel.text isEqualToString:@"政府机关"])
//        {
//            [self.customerInsideDit setObject:@"C1" forKey:@"NATURE_ID"];
//        }
//        if([self.editNewbutton2.titleLabel.text isEqualToString:@"企事业单位"])
//        {
//            [self.customerInsideDit setObject:@"C2" forKey:@"NATURE_ID"];
//        }
//        if([self.editNewbutton2.titleLabel.text isEqualToString:@"私人"])
//        {
//            [self.customerInsideDit setObject:@"C3" forKey:@"NATURE_ID"];
//        }
        //联系人
        if(self.editNewfield4.text == nil || [self.editNewfield4.text isEqualToString:@""])
        {
            self.editNewfield4.text = @"";
            
        }else
        {
            NSString *strB = [self.editNewfield4.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [self.customerInsideDit setObject:strB forKey:@"CONTACT_MAN"];
        }
        
        //联系电话
        if(self.editNewfield5.text != nil)
        {
            [self.customerInsideDit setObject:self.editNewfield5.text forKey:@"TEL"];
        }
        //所在地区
        [self.customerInsideDit setObject:self.provinceId forKey:@"PROVINCE"];
        [self.customerInsideDit setObject:self.cityId forKey:@"CITY"];
        [self.customerInsideDit setObject:self.countyId forKey:@"DISTRICT"];
       //[self serchPCD];
        //联系地址
        if(self.editNewfield6.text == nil || [self.editNewfield6.text isEqualToString:@""])
        {
            self.editNewfield6.text = @"";
        }else{
             NSString *strB = [self.editNewfield6.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            [self.customerInsideDit setObject:strB forKey:@"ADDRESS"];

        }
                //邮编
        if(self.editNewfield7.text == nil || [self.editNewfield7.text isEqualToString:@""])
        {
            self.editNewfield7.text = @"";
        }
        [self.customerInsideDit setObject:self.editNewfield7.text forKey:@"ZIP_CODE"];
        //传真
//        if(self.editNewfield8.text == nil || [self.editNewfield8.text isEqualToString:@""])
//        {
//            self.editNewfield8.text = @"";
//        }
//        [self.customerInsideDit setObject:self.editNewfield8.text forKey:@"fax"];
        //性别
        if([self.editNewbutton3.titleLabel.text isEqualToString:@"男"])
        {
            [self.customerInsideDit setObject:@"10061001" forKey:@"GENDER"];
        }
        if([self.editNewbutton3.titleLabel.text isEqualToString:@"女"])
        {
            [self.customerInsideDit setObject:@"10061002" forKey:@"GENDER"];
        }
        //出生日期
        if(self.editNewbutton4.titleLabel.text == nil || [self.editNewbutton4.titleLabel.text isEqualToString:@""])
        {
            self.editNewbutton4.titleLabel.text = @"";
        }
        [self.customerInsideDit setObject:self.editNewbutton4.titleLabel.text forKey:@"BIRTHDAY"];
        //证件类型
        if(self.editNewbutton5.titleLabel.text == nil || [self.editNewbutton5.titleLabel.text isEqualToString:@""])
        {
            self.editNewbutton5.titleLabel.text = @"";
        }else
        {
//             NSString *strB = [self.editNewbutton5.titleLabel.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [self.customerInsideDit setObject:self.CTtypeID forKey:@"CERTIFICATE_TYPE"];
        }
        
        //证件号码
        if(self.editNewfield9.text == nil || [self.editNewfield9.text isEqualToString:@""])
        {
            self.editNewfield9.text = @"";
        }
        [self.customerInsideDit setObject:self.editNewfield9.text forKey:@"CERTIFICATE"];
//        //职业
//        if(self.editNewbutton6.titleLabel.text != nil)
//        {
//            [self.customerInsideDit setObject:self.professionId forKey:@"job"];
//        }
        //兴趣爱好
        if(self.editNewbutton7.titleLabel.text != nil)
        {
            [self.customerInsideDit setObject:self.hobbyId forKey:@"HOBBIES"];
        }
        //婚姻状况
        if([self.editNewbutton8.titleLabel.text isEqualToString:@"未婚"])
        {
            [self.customerInsideDit setObject:@"11191001" forKey:@"MARITAL"];
        }
        if([self.editNewbutton8.titleLabel.text isEqualToString:@"已婚"])
        {
            [self.customerInsideDit setObject:@"11191002" forKey:@"MARITAL"];
        }
        //生产厂家
//        if(self.editNewbutton9.titleLabel.text != nil)
//        {
//            [self.customerInsideDit setObject:self.carShopId forKey:@"originalfactory"];
//        }
//        //车辆品牌
//        if(self.editNewbutton10.titleLabel.text != nil)
//        {
//            [self.customerInsideDit setObject:self.brandId forKey:@"originalcar"];
//        }
        //备注
        if(self.noteTextView.text == nil || [self.noteTextView.text isEqualToString:@""])
        {
            self.noteTextView.text = @"";
        }else{
            NSString * str = [self.noteTextView.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [self.customerInsideDit setObject:str forKey:@"REMARK"];
        }
        if (self.editNewfield1.text ==nil || [self.editNewfield1.text isEqualToString:@""]) {
           
        }else{
         [self.customerInsideDit setObject:self.editNewfield1.text forKey:@"CUSTOMER_ID"];
        }
        
        //测试
//        [self.customerInsideDit setObject:self.ceshi.text forKey:@"Ispayclient"];
        NSLog(@"%@",self.customerInsideDit);
//        webService *web = [[webService alloc]init];
//        web.methodName = CREATEREPAIRCUSTOMER;
//        
//        [web commonPostSharedRequest:CREATEREPAIRCUSTOMER psotDic:self.customerInsideDit];
//        NSLog(@"新增保存的字典：%@",self.customerInsideDit);
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            //api调用及返回
            [MyAFNetWorkManager postWithParam:self.customerInsideDit andAction:@"MAINTAIN_OWNER_FOR_PAD" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
                [SVProgressHUD dismiss];
                if (error == nil)
                {
                    NSLog(@"车主新增 json is %@",obj);
                    if ([obj[@"SUCCESS"] integerValue] == 1) {
                        
                        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"车主新增信息添加成功！" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                        [alertView show];
                        
                     [self.navigationController popToRootViewControllerAnimated:YES];
                    
                  
//                    NSString * ss = [obj objectForKey:@"OWNER_NO_RETURN"];
//                    self.editNewfield1.text = ss;
                    }
//                NSDictionary *dic = obj;
//                  if([[dic valueForKey:@"SUCCESS"] integerValue]==1)
//                 {
//                    
//                        NSArray *array = [dic objectForKey:@"TM_OWNER"];
//                     for (NSDictionary *ddic in array) {
//                        
//                     }
//                  }
                }
                else{
                    [SVProgressHUD showErrorWithStatus:error.localizedDescription];
                }
                
            }];
        });

   }
}
-(void)createRepairCustomer:(NSNotification*)notification
{
    NSMutableDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData *)notification.object options:NSJSONReadingMutableLeaves error:nil];
    if([[theJson valueForKey:@"error_code"] intValue])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[theJson valueForKey:@"error_msg"] message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else
    {
        [self.navigationController popViewControllerAnimated:YES];
        [self removeNotification];
    }
}

#pragma mark------------- 三列label
-(void)content
{
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setImage:[UIImage imageNamed:@"返回.png"] forState:UIControlStateNormal];
    [backButton setFrame:CGRectMake(70, 35, 45, 60)];
    [backButton addTarget:self action:@selector(NewCustomerBack:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backButton];
    
    UILabel *jiedai = [[UILabel alloc]initWithFrame:CGRectMake(160, 53, 200, 40)];
    
    jiedai.text = @"新增客户资料";
    if ([_CLStatus isEqualToString:@"bj"]) {
         jiedai.text = @"编辑客户资料";
    }
    jiedai.backgroundColor = [UIColor clearColor];
    jiedai.textColor = [UIColor grayColor];
    jiedai.font = [UIFont systemFontOfSize:28];
    [self.view addSubview:jiedai];
    
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(20, 110, 1000, 11)];
    image.image = [UIImage imageNamed:@"渐变分割线.png"];
    [self.view addSubview:image];
    
    NSMutableArray *labelMutabelArray = [[NSMutableArray alloc]initWithObjects:@"客户编号:",@"客户名称:",@"手  机  号:",@"客户性质:",@"联  系  人:",@"联系电话:",@"所在地区:",@"备       注:", nil];
    for(int i = 0; i < 8;i++)
    {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(15, (65+i*45), 100, 25)];
        [titlelabel setBackgroundColor:[UIColor clearColor]];
        titlelabel.text = [labelMutabelArray objectAtIndex:i];
        titlelabel.textColor = [UIColor grayColor];
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:16];
        //[titlelabel setTextAlignment:NSTextAlignmentCenter];
        [self.containerView addSubview:titlelabel];
    }
    NSMutableArray *labelMutabelArray2 = [[NSMutableArray alloc]initWithObjects:@"联系地址:",@"邮       编:",@"性       别:",@"出生日期:",@"证件类型:",@"证件号码:", nil];
    for(int i = 0; i < 6;i++)
    {
        UILabel *titlelabel2 = [[UILabel alloc]initWithFrame:CGRectMake(300, (65+i*45), 95, 25)];
        [titlelabel2 setBackgroundColor:[UIColor clearColor]];
        titlelabel2.text = [labelMutabelArray2 objectAtIndex:i];
        titlelabel2.textColor = [UIColor grayColor];
        titlelabel2.font = [UIFont fontWithName:@"ArialMT" size:16];
        [self.containerView addSubview:titlelabel2];
    }
    NSMutableArray *labelMutabelArray3 = [[NSMutableArray alloc]initWithObjects:@"兴趣爱好:",@"婚姻状况:", nil];
    for(int i = 0; i < 2;i++)
    {
        UILabel *titlelabel3 = [[UILabel alloc]initWithFrame:CGRectMake(580, (115+i*45), 95, 25)];
        [titlelabel3 setBackgroundColor:[UIColor clearColor]];
        titlelabel3.text = [labelMutabelArray3 objectAtIndex:i];
        titlelabel3.textColor = [UIColor grayColor];
        titlelabel3.font = [UIFont fontWithName:@"ArialMT" size:16];
        [self.containerView addSubview:titlelabel3];
    }
    for(int i = 0; i < 6;i++)
    {
        UIImageView *xingxingimage = [[UIImageView alloc]initWithFrame:CGRectMake(5, (115+i*45), 10, 10)];
        [xingxingimage setImage:[UIImage imageNamed:@"xingxing.png"]];
        [self.containerView addSubview:xingxingimage];
    }
}
-(void)NewCustomerBack:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
    [self removeNotification];
}
//********** 客户来源
-(void)editNewbutton1:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton7.frame.size.width, 200)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
    [carTypeArray addObject:@"自然来店"];
    [carTypeArray addObject:@"保有增购/换购"];
    [carTypeArray addObject:@"情报提供"];
    [carTypeArray addObject:@"店外开发"];
    [carTypeArray addObject:@"保有推介"];
    contentCon.list = carTypeArray;
    [contentCon.myTableView reloadData];

}
//********** 客户性质
-(void)editNewbutton2:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton2.frame.size.width, 80)];
    
    NSMutableArray *carTypeArray=[[NSMutableArray alloc]initWithCapacity:10];
//    [carTypeArray addObject:@"政府机关"];
//    [carTypeArray addObject:@"企事业单位"];
//    [carTypeArray addObject:@"私人"];
    [carTypeArray addObject:@"公司"];
    [carTypeArray addObject:@"个人"];
    contentCon.list = carTypeArray;
    
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [contentCon.myTableView reloadData];
}
//********** 性别
-(void)editNewbutton3:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton7.frame.size.width, 80)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
    [carTypeArray addObject:@"女"];
    [carTypeArray addObject:@"男"];
    
    contentCon.list = carTypeArray;
    [contentCon.myTableView reloadData];
}
//********** 出生日期
-(void)editNewbutton4:(id)sender
{
    self.datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 160)];
    self.datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    self.datePicker.datePickerMode = UIDatePickerModeDate;
    
    [self.datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
    //
    panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:self.datePicker];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = CGSizeMake(280.0f, 160.0f);
    
    [self.popCon presentPopoverFromRect:CGRectMake(70, 0, 5, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged:(id)sender
{
    UIDatePicker *contro = (UIDatePicker*)sender;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *str = [formatter stringFromDate:contro.date];
    [self.editNewbutton4 setTitle:str forState:UIControlStateNormal];
}
//********** 证件类型
-(void)editNewbutton5:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton7.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
   
//    [carTypeArray addObject:@"身份证"];
//    [carTypeArray addObject:@"护照"];
//    [carTypeArray addObject:@"军官证"];
//    [carTypeArray addObject:@"其他证件"];
    NSArray *zidianArr=[self readershuDICimform][@"CT_CODE"];
    NSMutableArray *containerArr = [[NSMutableArray alloc]init];
    [self.CTtypeArray removeAllObjects];
    //
    for(NSDictionary *dic in zidianArr)
    {
        [containerArr addObject:dic[@"NAME"]];
        [self.CTtypeArray addObject:dic[@"CODE"]];
    }
    
    contentCon.list = containerArr;
    [contentCon.myTableView reloadData];
}
//********** 职业
-(void)editNewbutton6:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton7.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    NSMutableArray *profession = [[NSMutableArray alloc]init];
    self.professionIdArray = [self.dicTmp objectForKey:@"profession"];
    for(int i = 0;i < [[self.dicTmp objectForKey:@"profession"]count];i++)
    {
        [profession addObject:[[[self.dicTmp objectForKey:@"profession"] objectAtIndex:i]objectForKey:@"value"]];
    }
    contentCon.list = profession;
    [contentCon.myTableView reloadData];
}
//********** 兴趣爱好
-(void)editNewbutton7:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton7.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
   NSMutableArray *hobby = [[NSMutableArray alloc]init];
    NSArray *zidianArr=[self readershuDICimform][@"TM_HOBBY"];
  
    [self.hobbyIdArray removeAllObjects];
    //
    for(NSDictionary *dic in zidianArr)
    {
        [hobby addObject:dic[@"NAME"]];
        [self.hobbyIdArray addObject:dic[@"CODE"]];
    }
//    self.hobbyIdArray = [self.dicTmp objectForKey:@"hobby"];
//    for(int i = 0;i < [[self.dicTmp objectForKey:@"hobby"]count];i++)
//    {
//        [hobby addObject:[[[self.dicTmp objectForKey:@"hobby"] objectAtIndex:i]objectForKey:@"value"]];
//    }
    contentCon.list = hobby;
    [contentCon.myTableView reloadData];
}
//********** 婚姻状况
-(void)editNewbutton8:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton8.frame.size.width, 80)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
    [carTypeArray addObject:@"未婚"];
    [carTypeArray addObject:@"已婚"];
    
    contentCon.list = carTypeArray;
    [contentCon.myTableView reloadData];
}
//********** 生产厂家
-(void)editNewbutton9:(id)sender
{
    self.editNewbutton10.titleLabel.text = @"";
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton9.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    NSMutableArray *hobby = [[NSMutableArray alloc]init];
    self.carShopArray = [self.dicTmp objectForKey:@"car_shop"];
    for(int i = 0;i < [[self.dicTmp objectForKey:@"car_shop"]count];i++)
    {
        [hobby addObject:[[[self.dicTmp objectForKey:@"car_shop"] objectAtIndex:i]objectForKey:@"value"]];
    }
    contentCon.list = hobby;
    [contentCon.myTableView reloadData];
}
//********** 车辆品牌
-(void)editNewbutton10:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.editNewbutton10.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    int index = [self.carShopNumber intValue];
    NSMutableArray *brand = [[NSMutableArray alloc]init];
    self.carShopArray = [[[self.dicTmp objectForKey:@"car_shop"] objectAtIndex:index] objectForKey:@"brand"];
    for(int i = 0;i < [[[[self.dicTmp objectForKey:@"car_shop"] objectAtIndex:index] objectForKey:@"brand"]count];i++)
    {
        [brand addObject:[[[[[self.dicTmp objectForKey:@"car_shop"] objectAtIndex:index] objectForKey:@"brand"]objectAtIndex:i] objectForKey:@"value"]];
    }
    contentCon.list = brand;
    [contentCon.myTableView reloadData];
}
//弹出回调方法
-(void)selectDelegate:(NSInteger)row btn:(UIButton *)btn
{
//    NSLog(@"selectDelegate:");
    NSMutableArray *xingBieArray = [[NSMutableArray alloc]initWithObjects:@"F",@"M" ,nil];//性别
    NSMutableArray *hunYinArray = [[NSMutableArray alloc]initWithObjects:@"S",@"M", nil];//婚姻状况

    if(btn == self.editNewbutton3)
    {
        self.xingBieId = [xingBieArray objectAtIndex:row];
    }
    else if (btn == self.editNewbutton5){
        self.CTtypeID = [self.CTtypeArray objectAtIndex:row];
    }
    else if(btn == self.editNewbutton8)
    {
        self.hunYinId = [hunYinArray objectAtIndex:row];
    }
    else if(btn == self.editNewbutton6)//职业
    {
        self.professionId = [[self.professionIdArray objectAtIndex:row]objectForKey:@"key"];
    }
    else if(btn == self.editNewbutton7)//兴趣爱好
    {
        self.hobbyId = [self.hobbyIdArray objectAtIndex:row];
    }
    else if(btn == self.editNewbutton9)//生产厂家
    {
        self.carShopId = [[self.carShopArray objectAtIndex:row]objectForKey:@"key"];
        self.carShopNumber = [NSString stringWithFormat:@"%d",row];
    }
    else if(btn == self.editNewbutton10)//车辆品牌
    {
        self.brandId = [[self.carShopArray objectAtIndex:row]objectForKey:@"key"];
//        NSLog(@"%@",self.brandId);
    }
    else if(btn == self.diQuSheng)//省
    {
        self.provinceId = [self.provinceArray objectAtIndex:row];
        NSLog(@"%@",self.provinceId);
//        self.provinceId = [[self.provinceArray objectAtIndex:row]objectForKey:@"area"];
//        self.provinceNumber = [NSString stringWithFormat:@"%d",row];
//        
//        [self.diQuShi setTitle:[[[[[self.dicTmp objectForKey:@"area"]objectAtIndex:row]objectForKey:@"subArea"]objectAtIndex:0]objectForKey:@"value"] forState:UIControlStateNormal];
//        
//        [self.diQuDiqu setTitle:[[[[[[[self.dicTmp objectForKey:@"area"]objectAtIndex:row]objectForKey:@"subArea"]objectAtIndex:0]objectForKey:@"subArea"]objectAtIndex:0]objectForKey:@"value"] forState:UIControlStateNormal];
    }
    else if(btn == self.diQuShi)//市
    {
//        self.cityId = [[self.cityArray objectAtIndex:row]objectForKey:@"subArea"];
//        self.cityNumber = [NSString stringWithFormat:@"%d",row];
        self.cityId = [self.cityArray objectAtIndex:row];
    }
    else if (btn == self.diQuDiqu){
        self.countyId = [[self.countyArray objectAtIndex:row] stringValue];
    }
    [self.popCon dismissPopoverAnimated:YES];
    self.popCon = nil;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSMutableDictionary *)readershuDICimform
{
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path=[paths objectAtIndex:0];
    NSString *str=[path stringByAppendingPathComponent:@"Dic.text"];
    dic=[NSMutableDictionary dictionaryWithContentsOfFile:str];
    //nslog(@"%@",dic);
    return dic;
}

-(void)diQuSheng:(id)sender
{
    self.diQuShi.titleLabel.text = nil;
    self.diQuDiqu.titleLabel.text = nil;
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.diQuSheng.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 110, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    

  
    
    
   NSArray *zidianArr=[self readershuDICimform][@"PROVINCE"];
    NSMutableArray *containerArr = [[NSMutableArray alloc]init];
   [self.provinceArray removeAllObjects];
//    
    for(NSDictionary *dic in zidianArr)
    {
        [containerArr addObject:dic[@"NAME"]];
        [self.provinceArray addObject:dic[@"CODE"]];
    }
    contentCon.list = containerArr;
//    for(int i = 0; i < [self.provinceArray count]; i++)
//    {
//        [container addObject:[[self.provinceArray objectAtIndex:i]objectForKey:@"value"]];
//    }
    
    [contentCon.myTableView reloadData];
}
-(void)diQuShi:(id)sender
{
    self.diQuDiqu.titleLabel.text = nil;
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.diQuSheng.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 110, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
//    int index = [self.provinceNumber intValue];
//    NSMutableArray *container = [[NSMutableArray alloc]init];
//    self.cityArray = [NSMutableArray arrayWithArray:[[[self.dicTmp objectForKey:@"area"] objectAtIndex:index] objectForKey:@"subArea"]];
//    for(int i = 0; i < [self.cityArray count]; i++)
//    {
//        [container addObject:[[self.cityArray objectAtIndex:i]objectForKey:@"value"]];
//    }
    NSArray *zidianArr=[self readershuDICimform][@"CITY"];
    NSMutableArray *containerArr = [[NSMutableArray alloc]init];
    [self.cityArray removeAllObjects];
    NSLog(@"self.provinceId:%@",self.provinceId);
   
    for(NSDictionary *dic in zidianArr)
    {
        NSNumber *G_CODE = dic[@"GROUP_CODE"];
        if (G_CODE.integerValue==self.provinceId.integerValue) {
            [containerArr addObject:dic[@"NAME"]];
            [self.cityArray addObject:dic[@"CODE"]];
        }
    }

    contentCon.list = containerArr;
    
    [contentCon.myTableView reloadData];
}
-(void)diQuDiqu:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.diQuSheng.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(20, 10, 110, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
//    int index = [self.cityNumber intValue];
//    NSMutableArray *container = [[NSMutableArray alloc]init];
//    self.countyArray = [NSMutableArray arrayWithArray:[[self.cityArray objectAtIndex:index] objectForKey:@"subArea"]];
//    for(int i = 0; i < [self.countyArray count]; i++)
//    {
//        [container addObject:[[self.countyArray objectAtIndex:i]objectForKey:@"value"]];
//    }
//    contentCon.list = container;
    
    NSArray *zidianArr=[self readershuDICimform][@"AREA"];
    NSMutableArray *containerArr = [[NSMutableArray alloc]init];
    [self.countyArray removeAllObjects];
    NSLog(@"self.cityId :%@",self.cityId);
   
    for(NSDictionary *dic in zidianArr)
    {
         NSNumber *G_CODE = dic[@"GROUP_CODE"];
       if (G_CODE.integerValue==self.cityId.integerValue) {
            [containerArr addObject:dic[@"NAME"]];
            [self.countyArray addObject:dic[@"CODE"]];
        }
    }
    
    
    contentCon.list = containerArr;
    [contentCon.myTableView reloadData];
}




//通过名字查找省市地的Id
-(void)serchPCD
{
//    NSLog(@"他妈的省：%@",self.diQuSheng.titleLabel.text);
//    NSLog(@"他妈的市：%@",self.diQuShi.titleLabel.text);
//    NSLog(@"他妈的区：%@",self.diQuDiqu.titleLabel.text);
    //查找省
    NSMutableArray *container = [[NSMutableArray alloc]init];
    NSMutableArray *nameS = [[NSMutableArray alloc]init];
    NSMutableArray *provinceArray = [NSMutableArray arrayWithArray:[self.dicTmp objectForKey:@"area"]];
    for(int i = 0; i < [provinceArray count]; i++)
    {
        [container addObject:[[provinceArray objectAtIndex:i]objectForKey:@"key"]];
        [nameS addObject:[[provinceArray objectAtIndex:i] objectForKey:@"value"]];
    }
//    NSString *str = [[container objectAtIndex:[nameS indexOfObject:self.diQuSheng.titleLabel.text]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    //查找市
    NSMutableArray *container2 = [[NSMutableArray alloc]init];
    NSMutableArray *nameY = [[NSMutableArray alloc]init];
    NSMutableArray *cityArray = [NSMutableArray arrayWithArray:[[provinceArray objectAtIndex:[nameS indexOfObject:self.diQuSheng.titleLabel.text]] objectForKey:@"subArea"]];
    for(int i = 0; i < [cityArray count]; i++)
    {
        [container2 addObject:[[cityArray objectAtIndex:i]objectForKey:@"key"]];
        [nameY addObject:[[cityArray objectAtIndex:i] objectForKey:@"value"]];
    }
//    NSString *str2 = [[container2 objectAtIndex:[nameY indexOfObject:self.diQuShi.titleLabel.text]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
   
    //查找地区
    NSMutableArray *container3 = [[NSMutableArray alloc]init];
    NSMutableArray *nameD = [[NSMutableArray alloc]init];
    NSMutableArray *countyArray = [NSMutableArray arrayWithArray:[[cityArray objectAtIndex:[nameY indexOfObject:self.diQuShi.titleLabel.text]] objectForKey:@"subArea"]];
    for(int i = 0; i < [countyArray count]; i++)
    {
        [container3 addObject:[[countyArray objectAtIndex:i]objectForKey:@"key"]];
        [nameD addObject:[[countyArray objectAtIndex:i] objectForKey:@"value"]];
    }
//    NSString *str3 = [[container3 objectAtIndex:[nameD indexOfObject:self.diQuDiqu.titleLabel.text]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
   
//    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:self.customerInsideDit];
//    [dict setObject:str forKey:@"province"];
//    [dict setObject:str2 forKey:@"city"];
//    [dict setObject:str3 forKey:@"district"];
//    self.customerInsideDit = dict;
    
//    NSLog(@"他妈的省：%@",[self.customerInsideDit objectForKey:@"province"]);
//    NSLog(@"他妈的市：%@",[self.customerInsideDit objectForKey:@"city"]);
//    NSLog(@"他妈的区：%@",[self.customerInsideDit objectForKey:@"district"]);
}

#pragma mark-----------textfieldDelegate
-(void)textFieldDidEndEditing:(UITextField *)textField{
    if (textField == self.editNewfield3) {
        if (textField.text.length>0 && textField.text.length != 11)
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"客户电话不合法，请重新输入" delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil];
            [alert show];
            
            
        }
    }
    
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if (textField == self.editNewfield3) {
        if (string.length == 0) return YES;
        
        NSInteger existedLength = textField.text.length;
        NSInteger selectedLength = range.length;
        NSInteger replaceLength = string.length;
        if (existedLength - selectedLength + replaceLength > 11) {
            return NO;
        }
    }
    
    return YES;
}
- (void)textFieldDidChange:(UITextField *)textField
{
    if (textField == self.editNewfield3) {
        if (textField.text.length > 11) {
            textField.text = [textField.text substringToIndex:11];
        }
    }
}
-(void)textViewDidBeginEditing:(UITextView *)textView
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.4];
    [self.view setFrame:CGRectMake(0, 0-200, 1024, 768)];
    [UIView commitAnimations];
}

-(void)textFieldDidBeginEditing:(UITextField *)textField     //弹出键盘的时候上提
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.4];
    [self.view setFrame:CGRectMake(0, 0-100, 1024, 768)];
    [UIView commitAnimations];
}
- (void)keyboardHide:(NSNotification *)notif   //键盘即将消失的时候点done归为view
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    [self.view setFrame:CGRectMake(0, 0, 1024, 768)];
    [UIView commitAnimations];
}
//-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//
//    [UIView beginAnimations:nil context:nil];
//    [UIView setAnimationDuration:0.3];
//    [self.view setFrame:CGRectMake(0, 0, 1024, 768)];
//    [UIView commitAnimations];
// 
//}
-(void)addNotification
{
    //车主信息新增
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(createRepairCustomer:) name:CREATEREPAIRCUSTOMER object:nil];
}
-(void)removeNotification
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}
@end
